<!DOCTYPE html>
<html>
<head>



    <template file="Home/meta" />
    <template file="Home/css" />






</head>
<body style="background:#fafafc">


<template file="Home/Cart/nav" />

<if condition="$cartlist['num']">




    <form method="post" class="form-horizontal J_ajaxForm" action='{:U("User/Order/check")}'>

    <div class="am-cf  am-padding-0 am-margin-top-sm">


        <volist name="cartlist.data" id="v">

            <div class="  am-g cart-list-item common-border-bottom  am-margin-vertical-sm  common-border-top common-border-bottom ">


                <div class="am-u-sm-4 am-text-center  list_img"><img src="{$v.thumb}" class="am-img-responsive"></div>
                <div class="am-u-sm-4 am-text-xs am-padding-left-0">




                    <a href="{:U('Home/Product/show',array('id'=>$v['product_id']))} " class="">
                        <h3 class="am-margin-0">
                        {$v.title}</h3>
                        <div class="sku am-text-999" >

                            颜色分类:{$v.color};尺码: {:F('Var_chicun')[$v["chicun"]][name]}:外框: {:F('Var_waikuang')[$v["waikuang"]][name]}</div>
                    </a>







                </div>


                <div class="am-u-sm-3 am-text-right am-padding-0">




                    <div class="">


                        <if condition="$u[vip]">
                        <span class="am-text-danger am-text-sm"> ￥ <span class="auto_price">{$v.price_huiyuan}</span></span>
                            <else/>
                            <span class="am-text-danger am-text-sm"> ￥ <span class="auto_price">{$v.price}</span></span>
                            </if>



                    </div>
                    <div class="cart-num">
x1

                        <!--<div class="am-input-group">-->
      <!--<span class="am-input-group-btn jian">-->
        <!--<button class="am-btn am-btn-default  " type="button">-->
            <!--<span class="am-icon-minus"></span></button>-->
      <!--</span>-->
                            <input type="hidden" min="0" name="product[{$key}]"
                                   class="am-form-field am-input-xs auto_num " value="{$v.num}" min="0"
                                   max="999" maxlength="3">



                                 <!--<span class="am-input-group-btn jia">-->
        <!--<button class="am-btn am-btn-default  " type="button" >-->
            <!--<span class="am-icon-plus"></span></button>-->
      <!--</span>-->
                        <!--</div>-->

                    </div>




                </div>



                <div class="am-u-sm-1 am-text-center am-padding-0">




                    <a class=" am-margin-top-lg  cart-del am-text-center" href='{:U("cart_dell",array("product_id"=>$key))}' style=" border: 1px  solid #666 ; border-radius:10px; width: 20px ;height:20px; display: inline-block; line-height: 18px ">
                        ×

                    </a>

                </div>
                </div>

        </volist>



    </div>







    <div data-am-widget="navbar" class="am-navbar am-cf am-navbar-index  common-border-top "
          style="height: 107px;">
        <div class="order-from-bottom am-text-right common-border-bottom ">

            <span class="am-margin-right-sm"> 合计：<span class="am-text-f60 " id="z_price">￥0</span></span>


            <button  class="am-btn  am-btn-danger am-btn-xl  ajax-post"  target-form="J_ajaxForm"  type="submit">结算</button>
        </div>
        <template file="Home/bottom_nav" />
    </div>
    </form>

<else/>



    <div class=" am-text-center  am-margin-vertical-lg am-padding-vertical-lg">


        <p>购物车块饿瘪了T.T</p>
        <p>快给我挑点宝贝吧</p>


        <a href="/Product/index" class=" btn-write am-padding-xs am-padding-horizontal-lg">去逛逛</a>


    </div>


    </if>







<template file="Home/js" />

<script>





    $(document).on("click",".cart-del",function(){

        var that=$(this);


        $.ajax({
            type: "GET",
            url: $(this).attr('href'),
            data: "att="+$(this).data('href'),
            success: function(data){


                if (data.status == '1') {
//                    $.scojs_message(data.info, $.scojs_message.TYPE_OK);

                    that.parents(".cart-list-item").remove();


                    s_check();
                }else{

                    $.scojs_message(data.info, $.scojs_message.TYPE_ERROR);
                }

            }

        });

        return false;

    });


    $(function(){


        s_check();




        $(".jia").click(function(){
            var input=$(this).prev(".auto_num");
            var n=input.val();
            var num=parseInt(n)+1;
            if(num==0){ return;}
            input.val(num);
            s_check();

        });

        //减的效果
        $(".jian").click(function(){
            var input=$(this).next(".auto_num");
            var n=input.val();
            var num=parseInt(n)-1;
            if(num==0){ return}
            input.val(num);
            s_check();
        });





    })



    function  s_check(){
        var sum=0;
        var sum_price=0;


        $(".cart-list-item ").each(function(){
//                $(this).hide();
            var v=$(this).val();


            num=$(this).find(".auto_num").val()





            price=$(this).find(".auto_price").html()




            price=parseInt(price);


            sum_price=sum_price+price*num;


        })



        $("#z_price").html("￥:"+sum_price);



    }


</script>

</body>
</html>